/*
 ============================================================================
 Name		: DocDetailContainer.h
 Author	  : JohnLZeng
 Copyright   : Your copyright notice
 Description : Declares container control for application.
 ============================================================================
 */

#ifndef DOCDETAILCONTAINER_H
#define DOCDETAILCONTAINER_H

// INCLUDES
#include <coecntrl.h>
#include <eiklabel.h> 
#include <eikrted.h> 
#include <AknsBasicBackgroundControlContext.h> 
#include <aknsdrawutils.h>
#include <aknscontrolcontext.h>
#include <AknsSkinInstance.h>
#include <aknsutils.h>
#include <aknview.h>
#include <MdaAudioSamplePlayer.h>
#include <e32cmn.h>
#include <fbs.h>
#include <GULICON.H>

#include "XmlParseNotify.h"
#include "BringToFrontTimer.h"

class CDocXmlParser;

// FORWARD DECLARATIONS

// CLASS DECLARATION

/**
 *  CDocDetailContainer  container control class.
 *  
 */
#define MAX_FONT_SIZE_HEIGHT	24
#define MIN_FONT_SIZE_HEIGHT	12
#define FONT_SIZE_CHANGE_OFFSET	4

class CDocDetailContainer : public CCoeControl, MCoeControlObserver ,MMdaAudioPlayerCallback
	{
public:
	enum TState
			{
			ENotReady,
			EReady,
			EPlaying,
			EPause
			};
	enum TDrawState
		{
		EDrawNone,
		EDrawPlay,
		EDrawPause,
		EDrawVolume
		};
	
public:
	// Constructors and destructor		
	~CDocDetailContainer();
	static CDocDetailContainer* NewL(const TRect& aRect);
	static CDocDetailContainer* NewLC(const TRect& aRect);

private:
	// New functions
	void ConstructL(const TRect& aRect);
	CDocDetailContainer();

public:
	// Functions from base classes
	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);

	void HandlePointerEventL(const TPointerEvent& aPointerEvent);
	
	//from MMdaAudioPlayerCallback
	virtual void MapcInitComplete(TInt aError,
			const TTimeIntervalMicroSeconds& aDuration);
	virtual void MapcPlayComplete(TInt aError);
	
private:
	// Functions from base classes
	void SizeChanged();
	TInt CountComponentControls() const;
	CCoeControl* ComponentControl(TInt aIndex) const;
	void Draw(const TRect& aRect) const;
	void HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType);

	TTypeUid::Ptr MopSupplyObject(TTypeUid aId);

	TBool ReadTextL();

	void Prepare();
	void SetupL();
	void IntroL();
	void SetAlignment(CParaFormat::TAlignment aAlignment);
	void SetColor(TRgb aColor);
	void SetFontAndColor(const CFont* aFont, TRgb aColor);
	void SetFontAndColor(TRgb aColor);
	void SetFont(const TInt& aHeight);
	
	void ClosePlayer();
	
	void InitEidtorControl();
	
	void InitIcon();
	void ReleaseIcon();
	void DrawAudioPlay(CWindowGc& gc) const;
	void DrawAudioPause(CWindowGc& gc) const;
	
	void Start();
	void Stop();
	static TInt Period( TAny* aPtr );
	void DoPeriodTask();
	void RenderIcon();
	
	void Mp3Init();
	void Change();
	void Mp3Volume();
	
	void InitVolumeBitmaps();
	void DrawVolumeBitmaps(CWindowGc& gc) const;

public:
	void Mp3Play();
	void Mp3Pause();
	void IncreaseVolume();
	void DecreaseVolume();
	
	void IncreaseFont();
	void DecreaseFont();
	
	TInt GetState() {return iState;};
private:
	//data
	//	CEikLabel*  iCaption ;
	CEikRichTextEditor* iRtEd; // Rich Text Editor
	HBufC* iText;

	CAknsBasicBackgroundControlContext* iBgContext;
	CBringToFrontTimer*	iActiveTimer;
	
	CFbsBitmap* iAudioPlayBmp;
	CFbsBitmap* iAudioPlayMask;
	CFbsBitmap* iAudioPauseBmp;
	CFbsBitmap* iAudioPauseMask;
	CFbsBitmap* iAudioSilenceBmp;
	CFbsBitmap* iAudioSilenceMask;
	CFbsBitmap* iAudioVolumeBmp;
	CFbsBitmap* iAudioVolumeMask;
	TInt iAudioFade;
	
	CPeriodic* iPeriodicTimer;
	
	CMdaAudioPlayerUtility* iMdaPlayer;
	TState iState;
	
	TInt iVolumeBrick;
	TInt iVolume;
//	RPointerArray<CGulIcon>* iVolumeOnBitmaps; 
//	RPointerArray<CGulIcon>* iVolumeOffBitmaps; 
	
	TDrawState iDrawState;
	};

#endif

